package com.mall.auth;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class AuthAccessDeniedHandler implements AccessDeniedHandler {
   @Override
   public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
      System.out.println("****************权限不足，访问失败！" + e.getMessage());
      request.setAttribute("msg", "权限不足，访问失败！!!");
      request.getRequestDispatcher("/login").forward(request, response);
   }
}